package com.okcoin.common;

import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;
import org.springframework.data.mongodb.core.MongoTemplate;

import java.util.ResourceBundle;
//spring不能注入多线程，所以吧mongo系列静态化
public class MongoConst {

    //库名
    public static final String DBNAME  =  ResourceBundle.getBundle("mongodb").getString("mongo.dbname");

    //ip
    public static final String HOST  = ResourceBundle.getBundle("mongodb").getString("mongo.host");

    //端口
    public static final int PORT  = Integer.parseInt(ResourceBundle.getBundle("mongodb").getString("mongo.port"));

    //public static final ServerAddress serverAddress = new ServerAddress(HOST, PORT);
    public static final  MongoClient MONGO_CLIENT = new MongoClient( new ServerAddress(HOST, PORT));

    public static final  MongoTemplate MONGO_TEMPLATE = new MongoTemplate(MongoConst.MONGO_CLIENT,MongoConst.DBNAME) ;

}
